package com.feizhoutuobang.shapeline.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.feizhoutuobang.shapeline.bo.Delivery;
import com.feizhoutuobang.shapeline.dao.DeliveryDao;

public class DeliveryDaoImpl extends HibernateDaoSupport implements DeliveryDao {

	@Override
	public void insertDelivery(Delivery delivery) {
		getHibernateTemplate().save("Delivery", delivery);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Delivery> getTodoDeliveries() {
		String hql = "from Delivery where done=false order by createTime_ desc";
		Query query = getSession().createQuery(hql);
		
		query.setFirstResult(0);
		query.setFetchSize(20);
		
		return query.list();
	}

	@Override
	public void updateDelivery(Delivery delivery) {
		getHibernateTemplate().update("Delivery", delivery);
	}
}
